package com.shanghaionstar.user.service;

import android.content.Context;

import com.onstar.cn.api.PublicService;
import com.onstar.cn.auth.CheckNewVersion;
import com.onstar.cn.common.util.Constants;
;
import com.onstar.cn.framework.annotation.http.HeadsValue;
import com.onstar.cn.framework.annotation.http.Request;
import com.onstar.cn.framework.mvp.base.core.BaseService;
import com.onstar.cn.framework.network.HttpInjectUtils;
import com.onstar.cn.framework.network.entity.RequestEntity;
import com.onstar.cn.framework.network.enumtype.HttpAccept;
import com.onstar.cn.framework.network.enumtype.HttpMethod;
import com.onstar.cn.framework.network.enumtype.Language;
import com.onstar.cn.framework.utils.GsonHelper;
import com.shanghaionstar.enumtype.OSTypeEnum;
import com.shanghaionstar.utils.BusinessUtil;
import com.shanghaionstar.utils.NetConnectUtil;

/**
 * Created by 7828wc on 16/7/11.
 */
public class AboutService extends BaseService<CheckNewVersion> {
    private Context context;

    public AboutService(Context context) {
        this.context = context;
    }

    @Override
    @Request(heads = @HeadsValue(accept = HttpAccept.JSON, language = Language.AUTO), method = HttpMethod.GET)
    public RequestEntity getRequestEntity() {
        RequestEntity requestEntity = NetConnectUtil.getAuthRequestEntity(context);
        PublicService publicService = new PublicService(Constants.CURRENT_SERVER_URL);
        requestEntity = publicService.appVersion(requestEntity, OSTypeEnum.ANDROID.value());
        requestEntity = HttpInjectUtils.injectHttp(getClass(), "getRequestEntity", requestEntity);
        return requestEntity;
    }

    @Override
    public CheckNewVersion jsonToBean(String json) {
        return GsonHelper.fromJson( json,CheckNewVersion.class);
    }
}
